package org.mbds.wolf.db;

import org.mbds.wolf.exception.UserException;
import org.mbds.wolf.exception.UserExceptionReason;

/**
 *
 * @author amles_000
 */
class DataInstruction {

    private byte[] ins;
    private DataInstructionType[] insTypes;
    private static DataInstruction instance = null;
    
    
    
    static DataInstruction init(DataInstructionType[] availableInsTypes, byte[] insValues) 
            throws UserException {
        if (availableInsTypes.length!=insValues.length)
            UserException.throwIt(UserExceptionReason.ARRAY_INDEX_OUT_OF_BOUND);
        if (instance==null) {
            instance = new DataInstruction(availableInsTypes, insValues);
        } else {
            instance.setInsTypes(availableInsTypes);
            instance.setIns(insValues);
        }
        return instance;
    }
    
    private DataInstruction(DataInstructionType[] availableInsTypes, byte[] insValues) {
        this.insTypes = availableInsTypes;
        this.ins = insValues;
    }
    
    

    private void setIns(byte[] ins) {
        this.ins = ins;
    }

    private void setInsTypes(DataInstructionType[] insTypes) {
        this.insTypes = insTypes;
    }

}
    
   